package 链式栈;
//刘超
public class test {
    public static void main(String[] args) throws Exception {
        LinkStack linkStack = new LinkStack();
        for (int i = 0; i < 10; i++) {
            linkStack.push(i+1);
        }
        linkStack.print();
        System.out.println("栈是否为空"+linkStack.isEmpty());
        System.out.println("出栈");
        linkStack.pop();
        System.out.println("打印");
        linkStack.print();
        System.out.println("栈顶元素"+linkStack.getTop());
        System.out.println("栈个数"+linkStack.size);

        int result=dataconverdion(100,2);
        System.out.println(result);
    }

    //数制转换
    //N表示十进制数，d表示要转换的进制
    public static int dataconverdion(int n,int d) throws Exception {
        LinkStack linkStack = new LinkStack();
        int result=0;
        while(n!=0){
            linkStack.push(n%d);
            n=n/d;
        }
//        linkStack.print();
       while(!linkStack.isEmpty()){
           result=result*10+(int)linkStack.pop();
       }
        return result;

    }
}
